
import random 
from GeometricalObjects import Point

def generate_point(id_point, max_x,max_y):
	x = random.randint(0,max_x-1)
	y = random.randint(0,max_y-1)
	return Point(id_point, x, y)

def generate_points(max_points, max_x, max_y):
	if max_x * max_y < max_points:
		raise BaseException("Impossible to generate this set of points within the defined grid")
	points = list()
	while len(points) != max_points: 
		#print("x {0}, y{1}".format(x,y))
		ok = False
		while not ok:
			point = generate_point(len(points), max_x, max_y)
			different = True
			for p in points:
				different = different and  (p.x != point.x or p.y != point.y)
			ok = different
		points.append(point)
	return points
